

package cn.shengchao.examstar.me.course.acl.adapters.clients;

import cn.shengchao.examstar.me.collect.acl.ports.message.CourseDto;
import cn.shengchao.examstar.me.course.acl.ports.clients.IProductClient;
import cn.shengchao.examstar.product.ohs.local.appservice.CourseService;
import cn.shengchao.examstar.product.ohs.local.appservice.ProductAppService;
import cn.shengchao.examstar.product.ohs.local.message.CourseListDto;
import cn.shengchao.examstar.product.ohs.local.message.KnowledgeNodeDto;
import cn.shengchao.examstar.product.ohs.local.message.ProductDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public class MyProductClient implements IProductClient {

    @Autowired
    private ProductAppService productAppService;

    @Autowired
    private CourseService courseService;

    @Override
    public Map<Long, String> getProductName(List<Long> knowledgeNodeIds) {
        return productAppService.getProductName(knowledgeNodeIds);
    }

    @Override
    public List<KnowledgeNodeDto> getKnowledgeListByNewOrder(Long courseId, String searchName, boolean isLesson) {
        return courseService.getKnowledgeListByNewOrder(courseId,searchName, isLesson);
    }

    @Override
    public List<KnowledgeNodeDto> getKnowledgeList(Long courseId, String searchName, boolean isLesson) {
        return courseService.getKnowledgeList(courseId,searchName, isLesson);
    }

    @Override
    public KnowledgeNodeDto getKnowledgeNodeDto(Long knowledgeNodeId) {
        return courseService.getKnowledgeNodeDto(knowledgeNodeId);
    }

    @Override
    public ProductDto getProduct(Long productId) {
        return productAppService.getProductById(String.valueOf(productId));
    }

    @Override
    public List<CourseDto> getProductList(List<Long> ids) {
        List<CourseListDto> course = courseService.getCourseListByIds(ids);
        return course.stream().map(CourseDto::of).toList();
    }

    @Override
    public Long getFreeUnlockSum(Long id) {
        return courseService.getFreeUnlockSum(id);
    }

    @Override
    public boolean isK12(Long courseId) {
        return courseService.isK12(courseId);
    }
}
